<?php

/*

Plugin Name:  SCRW Set Post Format By Category

Plugin URI: http://pauloflaherty.com

Description: Set the Post Format on save if post is in the correct category

Version: 0.1

Author: Paul O'Flaherty

Author URI: http://pauloflaherty.com

*/

add_action('publish_post', 'add_format_automatically');  
  
function add_format_automatically($post_id ) {
    if ( $parent = wp_is_post_revision( $post_id ) )
        $post_id = $parent;
    $post = get_post( $post_id );
    if ( $post->post_type != 'post' )
        return;
		
	// check to see which category
	
	if ( in_category( 'cute-pictures' )) {
	 set_post_format( $post_id , 'gallery');
	} elseif ( in_category( 'cute-videos' )) {
	set_post_format( $post_id , 'video');
	} else {
	// do nothing
}
}  
?>